<!DOCTYPE html>
<html lang="en" xmlns:th="www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>CRM</title>

    <!--CSS-->
    <!--bootstrap V3-->
    <link rel="stylesheet" th:href="@{/css/bootstrap.css}">
    <link rel="stylesheet" th:href="@{/css/dashboard.css}">
    <link rel="stylesheet" th:href="@{/css/bootstrapValidator.css}">
    <!--JS-->
    <script th:src="@{/js/jquery.min.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
    <script th:src="@{/js/holder.min.js}"></script>
    <script th:src="@{/js/bootstrapValidator.js}"></script>
</head>
<style>
    /*主页面样式*/
    .welcome-style {
        font-style: italic;
        font-size: 20px;
        display: inline-block;
        margin-top: 12px
    }

    .iframe {
        display: none;
    }

    .username-style {
        position: relative;
        display: inline-block;
        float: right;
        margin-top: 15px;
        font-size: 15px;
        margin-right: 35px;
    }

    .drop-menu-style {
        left: -45px;
        min-width: 0;
        top: 34px;
    }

    .li-menu-style {
        height: 50px;
    }

    .sidebar-style {
        padding: 0px;
        margin: 0px;
        width: 180px;
        background-color: white;
    }

    .list-group-style {
        padding-left: 40px;
        background-color: #f5f5f5;
        height: 60px;
        line-height: 60px;
        padding-bottom: 0px;
        padding-top: 0px;
    }

    .main-menu-style {
        position: absolute;
        left: 180px;
        top: 50px;
        width: 85%;
    }

    a {
        text-decoration: none;
        color: black;
        cursor: pointer;
    }

    .search-btn {
        position: relative;
        right: 30px;
        top: 4px;
        cursor: pointer;
    }

    .form-style {
        margin-top: 20px;
        margin-left: 20px;
    }

    th {
        text-align: center;
        line-height: 51px;
        vertical-align: middle;
    }

    td {
        vertical-align: middle;
        line-height: 51px;

    }

    /*主页面样式*/

    /*模态框样式*/
    .model-style {
        width: 70%;
    }

    .frame-style {
        width: 100%;
        height: 500px;
    }

    /*模态框样式*/

    /*修改用户信息表单样式*/
    .container-style {
        background-color: #f9fbff;
        height: 500px;
    }

    .col-top {
        margin-top: 20px;
        border-radius: 8px;
        box-shadow: 0 6px 32px -7px rgba(29, 102, 189, .16);
        height: auto;
        width: 750px;
        background-color: #fff;
    }

    .col-left {
        margin-left: 5px;
    }

    .form-group-div {
        margin-top: 20px;
        height: 50px;
    }

    .star-style {
        color: red;
        margin-left: 5px;
    }

    /*修改用户信息表单样式*/
</style>
<body>

<nav class="navbar navbar-inverse navbar-fixed-top" style="background-color: #f5f5f5">
    <div class="container-fluid">
        <div class="welcome-style">欢迎进入信息管理系统</div>
        <div class="username-style">
            <span class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
                  aria-expanded="false" th:text="${session.username}">
            </span>
            <input hidden="hidden" th:value="${session.username}" id="username">
            <input hidden="hidden" th:value="${session.userid}" id="userid">
            <input hidden="hidden" th:value="${session.usertype}" id="type">

            <span th:if="${session.username}==null">
                <a th:href="@{/user/toLogin}">您尚未登录，请先登录</a>
            </span>

            <ul class="dropdown-menu drop-menu-style">
                <li><a onclick="updateUserInfo($('#userid').val())" class="li-menu-style" style="line-height: 50px;">查看/修改个人信息</a>
                </li>
                <li><a th:href="@{/user/toLogin}" class="li-menu-style" style="line-height: 50px;">退出管理系统</a></li>
            </ul>
        </div>
        <!--查看/修改个人信息-->
        <div id="update_user_Model" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
             style="display: none;">
            <div class="modal-dialog model-style" role="document">
                <div class="modal-content">
                    <!--模态框的主体内容-->
                    <div class="modal-body" style="padding-right: 400px">
                        <div class="frame-style" style="height: 750px">
                            <!--修改用户信息页面-->
                            <div class="container-fluid container-style">
                                <div class="row">
                                    <div class="col-lg-7 col-lg-offset-3 col-top">
                                        <h1 style="text-align: center">修改用户信息页面</h1>
                                        <form id="update_user_Form" method="post" class="form-horizontal" action="">
                                            <div class="form-group form-group-div">
                                                <label class="col-lg-4 control-label">账号<span
                                                        class="star-style">*</span></label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="account"
                                                           id="user_account"/>
                                                </div>
                                            </div>

                                            <div class="form-group form-group-div">
                                                <label class="col-lg-4 control-label">密码<span
                                                        class="star-style">*</span></label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="password"
                                                           id="user_password"/>
                                                </div>
                                            </div>

                                            <div class="form-group form-group-div">
                                                <label class="col-lg-4 control-label">确认密码<span
                                                        class="star-style">*</span></label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="repassword"
                                                           id="repassword"/>
                                                </div>
                                            </div>

                                            <div class="form-group form-group-div">
                                                <label class="col-lg-4 control-label">联系方式<span
                                                        class="star-style">*</span></label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="tel" id="user_tel"/>
                                                </div>
                                            </div>

                                            <div class="form-group form-group-div">
                                                <label class="col-lg-4 control-label">姓名<span
                                                        class="star-style">*</span></label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="username"
                                                           id="user_name"/>
                                                </div>
                                            </div>

                                            <div class="form-group form-group-div">
                                                <label class="col-lg-4 control-label">电子邮箱</label>
                                                <div class="col-lg-5">
                                                    <input type="email" class="form-control" name="email"
                                                           id="user_email" data-toggle="popover"
                                                           data-content="<div style='width:140px;'>没有邮箱可先不填</div>"
                                                           data-trigger="focus"/>
                                                </div>
                                            </div>

                                            <div class="form-group form-group-div">
                                                <label class="col-lg-4 control-label">用户类型</label>
                                                <div class="col-lg-5">
                                                    <input type="text" class="form-control" name="usertype"
                                                           id="user_type" readonly data-toggle="popover"
                                                           data-content="<div style='width:180px;'>用户类型只有管理员能够修改</div>"
                                                           data-trigger="focus">
                                                </div>
                                            </div>

                                            <input type="hidden" name="usertype" id="usertype">

                                            <div class="form-group form-group-div">
                                                <div class="col-lg-8 col-lg-offset-4">
                                                    <button type="button" class="btn btn-primary col-left"
                                                            id="update_user">修改
                                                    </button>
                                                    <button type="reset" class="btn btn-primary col-left">重置</button>
                                                    <button type="button" class="btn btn-primary col-left"
                                                            data-toggle="popover"
                                                            data-content="注意:带<span style='color:red'>*</span>号的信息必须填写"
                                                            data-trigger="focus">修改规则
                                                    </button>
                                                    <button type="button" class="btn btn-warning col-left"
                                                            data-dismiss="modal">关闭
                                                    </button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!--修改信息表单-->
    </div>
</nav>
<div class="container-fluid">
    <div class="row">
        <div class="sidebar sidebar-style">
            <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="headingOne">
                        <h4 class="panel-title">
                            <a role="button" data-toggle="collapse" href="#collapseOne"
                               aria-expanded="false" aria-controls="collapseOne" style="padding-left: 30px;">
                                <!--data-parent="#accordion" 三个列表加上这个属性可以设置手风琴效果-->
                                个人客户管理
                            </a>
                        </h4>
                    </div>
                    <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel"
                         aria-labelledby="headingOne">
                        <ul class="list-group">
                            <li class="list-group-item list-group-style">
                                <a onclick="queryAllCustomer(1,3)" class="show">查看个人客户信息</a>
                            </li>
                            <li class="list-group-item list-group-style">
                                <a onclick="queryVisit(1,3)" class="show">个人客户拜访记录</a>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="panel panel-default" th:if="${session.usertype} lt 3">
                    <div class="panel-heading" role="tab" id="headingTwo">
                        <h4 class="panel-title">
                            <a class="collapsed " role="button" data-toggle="collapse"
                               href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"
                               style="padding-left: 30px">
                                员工管理
                            </a>
                        </h4>
                    </div>
                    <div id="collapseTwo" class="panel-collapse collapse " role="tabpanel" aria-labelledby="headingTwo">
                        <ul class="list-group">
                            <li class="list-group-item list-group-style"><a class="show" onclick="showalluser(1,3)">查看所有员工信息</a>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="panel panel-default" th:if="${session.usertype} lt 3">
                    <div class="panel-heading" role="tab" id="headingThree">
                        <h4 class="panel-title">
                            <a class="collapsed" role="button" data-toggle="collapse"
                               href="#collapseThree" aria-expanded="false" aria-controls="collapseThree"
                               style="padding-left: 30px">
                                客户管理
                            </a>
                        </h4>
                    </div>
                    <div id="collapseThree" class="panel-collapse collapse " role="tabpanel"
                         aria-labelledby="headingThree">
                        <ul class="list-group">
                            <li class="list-group-item list-group-style"><a class="show" onclick="showallcustomer(1,3)">查看所有客户</a>
                            </li>
                            <li class="list-group-item list-group-style"><a class="show" onclick="showallvisit(1,3)">所有客户拜访记录</a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <div class="iframe">
            <div class="main-menu-style">
                <form class="form-inline" id="search_form">
                    <div class="form-group form-style">
                        <input type="text" class="form-control" id="search_username" placeholder="查询客户信息...">
                        <span class="glyphicon glyphicon-search search-btn" onclick="custom_search(1,3)"></span>
                        <button type="button" class="btn btn-info" id="addcustomer">添加客户</button>
                    </div>
                </form>
                <hr>
                <!--修改客户信息表单模态框-->
                <div id="updateModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                     style="display: none;">
                    <div class="modal-dialog model-style" role="document">
                        <div class="modal-content">
                            <!--模态框的主体内容-->
                            <div class="modal-body" style="padding: 0px">
                                <div class="frame-style">
                                    <!--修改用户信息页面-->
                                    <div class="container-fluid container-style">
                                        <div class="row">
                                            <div class="col-lg-7 col-lg-offset-2 col-top">
                                                <h1 style="text-align: center">客户信息修改页面</h1>
                                                <form id="updateForm" method="post" class="form-horizontal" action="">
                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">客户姓名<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="name"
                                                                   id="name"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">客户地址<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="address"
                                                                   id="address"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">客户联系人<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="contact"
                                                                   id="contact"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">联系方式<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="tel"
                                                                   id="tel"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">电子邮箱</label>
                                                        <div class="col-lg-5">
                                                            <input type="email" class="form-control" name="email"
                                                                   id="email"
                                                                   data-toggle="popover"
                                                                   data-content="<div style='width:140px;'>没有邮箱可先不填</div>"
                                                                   data-trigger="focus"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <div class="col-lg-8 col-lg-offset-4">
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    id="customerupdate">修改
                                                            </button>
                                                            <button type="reset" class="btn btn-primary col-left">重置
                                                            </button>
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    data-toggle="popover"
                                                                    data-content="注意:带<span style='color:red'>*</span>号的信息必须填写"
                                                                    data-trigger="focus">修改规则
                                                            </button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--模态框的尾部内容-->
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!--修改信息表单-->

                <!--添加客户信息表单模态框-->
                <div id="addModel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                     style="display: none;">
                    <div class="modal-dialog model-style" role="document">
                        <div class="modal-content">
                            <!--模态框的主体内容-->
                            <div class="modal-body" style="padding: 0px">
                                <div class="frame-style">
                                    <!--修改用户信息页面-->
                                    <div class="container-fluid container-style">
                                        <div class="row">
                                            <div class="col-lg-7 col-lg-offset-2 col-top">
                                                <h1 style="text-align: center">客户信息添加页面</h1>
                                                <form id="addForm" method="post" class="form-horizontal" action="">
                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">客户姓名<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="name"
                                                                   id="add_name"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">客户地址<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="address"
                                                                   id="add_address"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">客户联系人<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="contact"
                                                                   id="add_contact"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">联系方式<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="tel"
                                                                   id="add_tel"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">电子邮箱</label>
                                                        <div class="col-lg-5">
                                                            <input type="email" class="form-control" name="email"
                                                                   id="add_email"
                                                                   data-toggle="popover"
                                                                   data-content="<div style='width:140px;'>没有邮箱可先不填</div>"
                                                                   data-trigger="focus"/>
                                                        </div>
                                                    </div>

                                                    <input type="hidden" name="isdelete" value="1">

                                                    <div class="form-group form-group-div">
                                                        <div class="col-lg-8 col-lg-offset-4">
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    id="customeradd">添加
                                                            </button>
                                                            <button type="reset" class="btn btn-primary col-left">重置
                                                            </button>
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    data-toggle="popover"
                                                                    data-content="注意:带<span style='color:red'>*</span>号的信息必须填写"
                                                                    data-trigger="focus">添加规则
                                                            </button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--模态框的尾部内容-->
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!--添加信息表单-->
                <!--客户表格-->

                <div>
                    <table class="table table-bordered">
                        <tr>
                            <th>客户编号</th>
                            <th>客户姓名</th>
                            <th>客户地址</th>
                            <th>客户联系人</th>
                            <th>客户电话</th>
                            <th>客户邮箱</th>
                            <th>所属用户</th>
                            <th>操作</th>
                        </tr>

                        <tbody id="tbody"></tbody>
                    </table>

                    <ul class="pagination" id="page_customer">

                    </ul>
                </div>
                <!--添加客户拜访信息表单模态框-->
                <div id="add_visit_Model" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                     style="display: none;">
                    <div class="modal-dialog model-style" role="document">
                        <div class="modal-content">
                            <!--模态框的主体内容-->
                            <div class="modal-body" style="padding: 0px">
                                <div class="frame-style" style="height: 350px">
                                    <!--添加客户拜户信息页面-->
                                    <div class="container-fluid container-style" style="height: 350px">
                                        <div class="row">
                                            <div class="col-lg-7 col-lg-offset-2 col-top" style="margin-top: 100px">
                                                <h1 style="text-align: center">客户拜访添加页面</h1>
                                                <form id="add_visit_Form" method="post" class="form-horizontal"
                                                      action="">
                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">拜访内容<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="content"
                                                                   id="add_visit_content"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <div class="col-lg-8 col-lg-offset-4">
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    id="visit_add">添加
                                                            </button>
                                                            <button type="reset" class="btn btn-primary col-left">重置
                                                            </button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--模态框的尾部内容-->
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!--添加拜访表单-->
                <!--共享客户信息表单模态框-->
                <div id="share_Model" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                     style="display: none;">
                    <div class="modal-dialog model-style" role="document">
                        <div class="modal-content">
                            <!--模态框的主体内容-->
                            <div class="modal-body" style="padding: 0px">
                                <div name="addCustom" class="frame-style" style="height: 350px">
                                    <!--添加客户拜户信息页面-->
                                    <div class="container-fluid container-style" style="height: 350px">
                                        <div class="row">
                                            <div class="col-lg-7 col-lg-offset-2 col-top" style="margin-top: 100px">
                                                <h1 style="text-align: center">分享客户</h1>
                                                <form id="share_Form" method="post" class="form-horizontal"
                                                      action="">
                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 col-lg-offset-1 control-label">
                                                            该客户共享给</label>
                                                        <select class="form-control" id="share_select"
                                                                style="width: 150px;text-align: center">

                                                        </select>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <div class="col-lg-8 col-lg-offset-5">
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    id="share_add">共享
                                                            </button>
                                                            <button type="reset" class="btn btn-primary col-left">重置
                                                            </button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--模态框的尾部内容-->
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!--共享客户信息表单-->
                <!--转移客户信息表单模态框-->
                <div id="trans_Model" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                     style="display: none;">
                    <div class="modal-dialog model-style" role="document">
                        <div class="modal-content">
                            <!--模态框的主体内容-->
                            <div class="modal-body" style="padding: 0px">
                                <div class="frame-style" style="height: 350px">
                                    <!--添加客户拜户信息页面-->
                                    <div class="container-fluid container-style" style="height: 350px">
                                        <div class="row">
                                            <div class="col-lg-7 col-lg-offset-2 col-top" style="margin-top: 100px">
                                                <h1 style="text-align: center">转移客户</h1>
                                                <form id="trans_Form" method="post" class="form-horizontal"
                                                      action="">
                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 col-lg-offset-1 control-label">
                                                            该客户转移给</label>
                                                        <select class="form-control" id="trans_select"
                                                                style="width: 150px;text-align: center">

                                                        </select>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <div class="col-lg-8 col-lg-offset-5">
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    id="trans_add">转移
                                                            </button>
                                                            <button type="reset" class="btn btn-primary col-left">重置
                                                            </button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--模态框的尾部内容-->
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!--转移客户信息表单-->
                <!--确认删除客户信息表单模态框-->
                <div id="del_Model" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                     style="display: none;">
                    <div class="modal-dialog model-style" style="width: 300px;font-size: 20px;top:60px" role="document">
                        <div class="modal-content">
                            <div class="modal-header">是否删除此客户?</div>
                            <!--模态框的尾部内容-->
                            <div class="modal-footer">
                                <button type="button" class="btn btn-danger"
                                        id="del_customer">删除
                                </button>
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!--确认删除客户信息表单-->
            </div>
        </div><!--列表一页面-->
        <div class="iframe"><!--列表二页面-->
            <div class="main-menu-style">
                <form class="form-inline" id="search_visit">
                    <div class="form-group form-style">
                        <input type="text" class="form-control" id="search_visit_username"
                               placeholder="查询拜访客户信息...">
                        <span class="glyphicon glyphicon-search search-btn" onclick="visit_search(1,3)"></span>
                    </div>
                </form>
                <hr>
                <div>
                    <table class="table table-bordered">
                        <tr>
                            <th>序号</th>
                            <th>客户编号</th>
                            <th>客户姓名</th>
                            <th>用户编号</th>
                            <th>用户姓名</th>
                            <th>拜访内容</th>
                            <th>拜访日期</th>
                            <th>操作</th>
                        </tr>
                        <tbody id="visit_tbody"></tbody>
                    </table>
                    <ul class="pagination" id="page_visit"></ul>
                </div>
                <!--修改客户拜访信息表单模态框-->
                <div id="update_visit_Model" class="modal fade" tabindex="-1" role="dialog"
                     aria-labelledby="myModalLabel"
                     style="display: none;">
                    <div class="modal-dialog model-style" role="document">
                        <div class="modal-content">
                            <!--模态框的主体内容-->
                            <div class="modal-body" style="padding: 0px">
                                <div name="updateCustom" class="frame-style" style="height: 350px">
                                    <!--修改客户拜访信息页面-->
                                    <div class="container-fluid container-style" style="height: 350px">
                                        <div class="row">
                                            <div class="col-lg-7 col-lg-offset-2 col-top" style="margin-top: 100px">
                                                <h1 style="text-align: center">客户拜访信息修改页面</h1>

                                                <form id="update_visit_Form" method="post" class="form-horizontal"
                                                      action="">
                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">拜访内容<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="content"
                                                                   id="visit_content"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <div class="col-lg-8 col-lg-offset-4">
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    id="update_visit">修改
                                                            </button>
                                                            <button type="reset" class="btn btn-primary col-left">重置
                                                            </button>
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    data-toggle="popover"
                                                                    data-content="注意:带<span style='color:red'>*</span>号的信息必须填写"
                                                                    data-trigger="focus">修改规则
                                                            </button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--模态框的尾部内容-->
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!--修改信息表单-->
            </div>
        </div><!--列表二页面-->
        <div class="iframe">
            <div class="main-menu-style">
                <form class="form-inline" id="search_user_form">
                    <div class="form-group form-style">
                        <input type="text" class="form-control" id="search_user_username" placeholder="查询员工信息...">
                        <span class="glyphicon glyphicon-search search-btn" onclick="user_search(1,3)"></span>
                        <button type="button" class="btn btn-info" onclick="insertUserInfo()">添加员工</button>
                    </div>
                </form>
                <hr>
                <div>
                    <table class="table table-bordered">
                        <tr>
                            <th>员工编号</th>
                            <th>员工账号</th>
                            <th>员工密码</th>
                            <th>员工联系方式</th>
                            <th>员工姓名</th>
                            <th>员工邮箱</th>
                            <th>在职状态</th>
                            <th>操作</th>
                        </tr>
                        <tbody id="tbody_user"></tbody>
                    </table>
                    <ul class="pagination" id="page_user"></ul>
                </div>
                <!--确认删除用户信息表单模态框-->
                <div id="del_user_Model" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                     style="display: none;">
                    <div class="modal-dialog model-style" style="width: 300px;font-size: 20px;top:60px" role="document">
                        <div class="modal-content">
                            <div class="modal-header">是否删除此用户?</div>
                            <!--模态框的尾部内容-->
                            <div class="modal-footer">
                                <button type="button" class="btn btn-danger"
                                        id="del_user">删除
                                </button>
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!--确认删除用户信息表单-->
                <!--添加用户信息表单-->
                <div id="insert_user_Model" class="modal fade" tabindex="-1" role="dialog"
                     aria-labelledby="myModalLabel"
                     style="display: none;">
                    <div class="modal-dialog model-style" role="document">
                        <div class="modal-content">
                            <!--模态框的主体内容-->
                            <div class="modal-body" style="padding-right: 400px">
                                <div class="frame-style" style="height: 750px">
                                    <!--修改用户信息页面-->
                                    <div class="container-fluid container-style">
                                        <div class="row">
                                            <div class="col-lg-7 col-lg-offset-3 col-top">
                                                <h1 style="text-align: center">添加用户信息页面</h1>
                                                <form id="insert_user_Form" method="post" class="form-horizontal"
                                                      action="">
                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">账号<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="account"
                                                                   id="insert_user_account"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">密码<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="password"
                                                                   id="insert_user_password"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">确认密码<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="repassword"
                                                                   id="insert_repassword"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">联系方式<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="tel"
                                                                   id="insert_user_tel"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">姓名<span
                                                                class="star-style">*</span></label>
                                                        <div class="col-lg-5">
                                                            <input type="text" class="form-control" name="username"
                                                                   id="insert_user_name"/>
                                                        </div>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 control-label">电子邮箱</label>
                                                        <div class="col-lg-5">
                                                            <input type="email" class="form-control" name="email"
                                                                   id="insert_user_email" data-toggle="popover"
                                                                   data-content="<div style='width:140px;'>没有邮箱可先不填</div>"
                                                                   data-trigger="focus"/>
                                                        </div>
                                                    </div>

                                                    <input type="hidden" name="usertype" id="insert_user_type"
                                                           value="3">

                                                    <div class="form-group form-group-div">
                                                        <div class="col-lg-8 col-lg-offset-4">
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    id="insert_user">添加
                                                            </button>
                                                            <button type="reset" class="btn btn-primary col-left">重置
                                                            </button>
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    data-toggle="popover"
                                                                    data-content="注意:带<span style='color:red'>*</span>号的信息必须填写"
                                                                    data-trigger="focus">添加规则
                                                            </button>
                                                            <button type="button" class="btn btn-warning col-left"
                                                                    data-dismiss="modal">关闭
                                                            </button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!--添加用户信息表单-->
                <!--更改用户权限信息表单模态框-->
                <div id="authority_Model" class="modal fade" tabindex="-1" role="dialog"
                     aria-labelledby="myModalLabel"
                     style="display: none;">
                    <div class="modal-dialog model-style" role="document">
                        <div class="modal-content">
                            <!--模态框的主体内容-->
                            <div class="modal-body" style="padding: 0px">
                                <div class="frame-style" style="height: 350px">
                                    <!--添加客户拜户信息页面-->
                                    <div class="container-fluid container-style" style="height: 350px">
                                        <div class="row">
                                            <div class="col-lg-7 col-lg-offset-2 col-top" style="margin-top: 100px">
                                                <h1 style="text-align: center">更改权限</h1>
                                                <form id="authority_Form" method="post" class="form-horizontal"
                                                      action="">
                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 col-lg-offset-1 control-label">
                                                            该用户类型更改为</label>
                                                        <select class="form-control" id="authority_select"
                                                                style="width: 150px;text-align: center">

                                                        </select>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <div class="col-lg-8 col-lg-offset-5">
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    id="authority_add">更改
                                                            </button>
                                                            <button type="reset" class="btn btn-primary col-left">重置
                                                            </button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--模态框的尾部内容-->
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!--更改用户权限信息表单-->
                
            </div>
        </div><!--列表三页面-->
        <div class="iframe">
            <div class="main-menu-style">
                <form class="form-inline" id="search_all_form">
                    <div class="form-group form-style">
                        <input type="text" class="form-control" id="search_all_username" placeholder="查询客户信息...">
                        <span class="glyphicon glyphicon-search search-btn" onclick="custom_all_search(1,3)"></span>
                    </div>
                </form>
                <hr>
                <div>
                    <table class="table table-bordered">
                        <tr>
                            <th>客户编号</th>
                            <th>客户姓名</th>
                            <th>客户地址</th>
                            <th>客户联系人</th>
                            <th>客户电话</th>
                            <th>客户邮箱</th>
                            <th>所属用户</th>
                            <th>操作</th>
                        </tr>
                        <tbody id="all_tbody"></tbody>
                    </table>

                    <ul class="pagination" id="page_all"></ul>

                </div>
                <!--转移客户信息表单模态框-->
                <div id="trans_custom_Model" class="modal fade" tabindex="-1" role="dialog"
                     aria-labelledby="myModalLabel"
                     style="display: none;">
                    <div class="modal-dialog model-style" role="document">
                        <div class="modal-content">
                            <!--模态框的主体内容-->
                            <div class="modal-body" style="padding: 0px">
                                <div class="frame-style" style="height: 350px">
                                    <!--添加客户拜户信息页面-->
                                    <div class="container-fluid container-style" style="height: 350px">
                                        <div class="row">
                                            <div class="col-lg-7 col-lg-offset-2 col-top" style="margin-top: 100px">
                                                <h1 style="text-align: center">转移客户</h1>
                                                <form id="trans_custom_Form" method="post" class="form-horizontal"
                                                      action="">
                                                    <div class="form-group form-group-div">
                                                        <label class="col-lg-4 col-lg-offset-1 control-label">
                                                            该客户转移给</label>
                                                        <select class="form-control" id="trans_custom_select"
                                                                style="width: 150px;text-align: center">

                                                        </select>
                                                    </div>

                                                    <div class="form-group form-group-div">
                                                        <div class="col-lg-8 col-lg-offset-5">
                                                            <button type="button" class="btn btn-primary col-left"
                                                                    id="trans_custom_add">转移
                                                            </button>
                                                            <button type="reset" class="btn btn-primary col-left">重置
                                                            </button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--模态框的尾部内容-->
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!--转移客户信息表单-->
            </div>

        </div><!--列表四页面-->
        <div class="iframe">
            <div class="main-menu-style">
                <form class="form-inline" id="search_all_visit">
                    <div class="form-group form-style">
                        <input type="text" class="form-control" id="search_visit_all"
                               placeholder="查询拜访客户信息...">
                        <span class="glyphicon glyphicon-search search-btn" onclick="visit_search_all(1,3)"></span>
                    </div>
                </form>
                <hr>
                <div>
                    <table class="table table-bordered">
                        <tr>
                            <th>序号</th>
                            <th>客户编号</th>
                            <th>客户姓名</th>
                            <th>用户编号</th>
                            <th>用户姓名</th>
                            <th>拜访内容</th>
                            <th>拜访日期</th>
                        </tr>
                        <tbody id="visit_all_tbody"></tbody>
                    </table>
                    <ul class="pagination" id="page_all_visit"></ul>
                </div>
            </div>
        </div><!--列表五页面-->
    </div>
</div>
</body>
<script type="text/javascript">
    //权限更改
    function authorityUser(id,authority){
        $("#authority_Model").modal("show");
        //选择器，选择要分享给的用户
        $.ajax({
            url: "/authority/selectAuthority",
            type: "POST",
            dataType: "json",
            success: (data) => {
                $("#authority_select").empty();
                let opt = '';
                for (let i = 0; i < data.length; i++) {
                    if (data[i].id !== authority) {
                        opt += '<option value="' + data[i].id + '">' + data[i].usertype + '</option>';
                    }
                }
                $("#authority_select").append(opt);
                //更改权限操作
                $("#authority_add").on('click', function () {
                    $.ajax({
                        url: '/user/updateUserInfo',
                        type: 'post',
                        data: {
                            id: id,
                            usertype: $("#authority_select").val(),
                        },
                        success: function (data) {
                            if (data === 1) {
                                alert("更改权限成功");
                                window.location.href = '/customer/toCrm';
                            }
                        }
                    })
                });
            },
        })
    }
    
    //重置用户密码
    function resetUserInfo(id){
        $.ajax({
            url:'/user/updateUserInfo',
            type: "POST",
            dataType: "json",
            data:{
                password:"123456",
                id:id,
            },
            success: function(data){
                if (data==1){
                    alert("重置成功");
                    window.location.href = '/customer/toCrm';
                }
            }
        })
        
            
    }
    
    //转移客户信息
    function transAllCustomer(id, username) {
        $("#trans_custom_Model").modal("show");
        //选择器，选择要分享给的用户
        $.ajax({
            url: "/user/selectUserInfo",
            type: "POST",
            dataType: "json",
            success: (data) => {
                $("#trans_custom_select").empty();
                let list = data.list;
                let opt = '';
                for (let i = 0; i < list.length; i++) {
                    if (list[i].username !== username) {
                        opt += '<option value="' + list[i].id + '">' + list[i].username + '</option>';
                    }
                }
                $("#trans_custom_select").append(opt);
                //点击转移客户信息
                $("#trans_custom_add").on('click', function () {
                    $.ajax({
                        url: '/customer/updateCustomer',
                        type: 'post',
                        data: {
                            id: id,
                            userid: $("#trans_custom_select").val(),
                        },
                        success: function (data) {
                            if (data === 1) {
                                alert("转移成功");
                                window.location.href = '/customer/toCrm';
                            }
                        }
                    })
                });
            },
        });
    }
    //按姓名查询客户拜访信息
    function visit_search(pageNum, pageSize) {
        $.ajax({
            url: '/visit/selectCustomerVisit',
            type: 'post',
            dataType: 'json',
            data: {
                userid: $("#userid").val(),
                name: $("#search_visit_username").val(),
                pageNum: pageNum,
                pageSize: pageSize,
            },
            success: function (data) {
                $("#page_visit").empty();
                var html = '';
                html += '<li class="page-item' + (data.isFirstPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="visit_search(' + 1 + ',' + data.pageSize + ')">首页</a></li>';

                // 上一页链接
                html += '<li class="page-item' + (!data.hasPreviousPage ? ' disabled' : '') + '">';
                var previous;
                if (data.pageNum === 1) {
                    previous = data.pageNum;
                } else {
                    previous = data.pageNum - 1;
                }

                html += '<a class="page-link" onclick="visit_search(' + previous + ',' + data.pageSize + ')">上一页</a></li>';

                // 分页数字链接
                for (var i = 1; i <= data.pages; i++) {
                    html += '<li class="page-item' + (data.pageNum === i ? ' active' : '') + '">';
                    html += '<a class="page-link" onclick="visit_search(' + i + ',' + data.pageSize + ')">' + i + '</a></li>';
                }
                var next;
                if (data.pageNum === data.pages) {
                    next = data.pageNum;
                } else {
                    next = data.pageNum + 1;
                }
                // 下一页链接
                html += '<li class="page-item' + (!data.hasNextPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="visit_search(' + next + ',' + data.pageSize + ')">下一页</a></li>';

                // 尾页链接
                html += '<li class="page-item' + (data.isLastPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="visit_search(' + data.pages + ',' + data.pageSize + ')">尾页</a></li>';

                $("#page_visit").append(html);

                $('#visit_tbody').empty();
                var id;
                // 循环遍历 JSON 数据并添加到表格中
                $.each(data.list, function (index, item) {
                    var row = '<tr>';
                    $.each(item, function (key, value) {
                        if (value != null) {
                            if (key === "id") {
                                id = value;
                            }
                            row += '<td style="text-align: center;">' + value + '</td>';
                        }
                    });
                    row += '<td><button type="button"  class="btn btn-warning"  onclick="editvisit(' + id + ')">修改</button></td></tr>';
                    $('#visit_tbody').append(row);
                });
            },
        });
    }

    //点击查看客户拜访信息
    function queryVisit(pageNum, pageSize) {
        $.ajax({
            url: '/visit/selectCustomerVisit',
            type: 'post',
            data: {
                userid: $("#userid").val(),
                pageNum: pageNum,
                pageSize: pageSize,
            },
            success: function (data) {
                $("#page_visit").empty();
                var html = '';
                html += '<li class="page-item' + (data.isFirstPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="queryVisit(' + 1 + ',' + data.pageSize + ')">首页</a></li>';

                // 上一页链接
                html += '<li class="page-item' + (!data.hasPreviousPage ? ' disabled' : '') + '">';
                var previous;
                if (data.pageNum === 1) {
                    previous = data.pageNum;
                } else {
                    previous = data.pageNum - 1;
                }

                html += '<a class="page-link" onclick="queryVisit(' + previous + ',' + data.pageSize + ')">上一页</a></li>';

                // 分页数字链接
                for (var i = 1; i <= data.pages; i++) {
                    html += '<li class="page-item' + (data.pageNum === i ? ' active' : '') + '">';
                    html += '<a class="page-link" onclick="queryVisit(' + i + ',' + data.pageSize + ')">' + i + '</a></li>';
                }
                var next;
                if (data.pageNum === data.pages) {
                    next = data.pageNum;
                } else {
                    next = data.pageNum + 1;
                }
                // 下一页链接
                html += '<li class="page-item' + (!data.hasNextPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="queryVisit(' + next + ',' + data.pageSize + ')">下一页</a></li>';

                // 尾页链接
                html += '<li class="page-item' + (data.isLastPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="queryVisit(' + data.pages + ',' + data.pageSize + ')">尾页</a></li>';

                $("#page_visit").append(html);


                $('#visit_tbody').empty();
                var id;
                // 循环遍历 JSON 数据并添加到表格中
                $.each(data.list, function (index, item) {
                    var row = '<tr>';
                    $.each(item, function (key, value) {
                        if (value != null) {
                            if (key === "id") {
                                id = value;
                            }
                            row += '<td style="text-align: center;">' + value + '</td>';
                        }
                    });
                    row += '<td><button type="button"  class="btn btn-warning"  onclick="editvisit(' + id + ')">修改</button></td></tr>';
                    $('#visit_tbody').append(row);
                });
            },
        });
    };//点击查看客户拜访信息

    //查看所有客户
    function showallcustomer(pageNum, pageSize) {
        $.ajax({
            url: '/customer/selectCustomer',
            type: 'post',
            data: {
                pageNum: pageNum,
                pageSize: pageSize,
            },
            success: function (data) {
                $("#page_all").empty();
                var html = '';
                html += '<li class="page-item' + (data.isFirstPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="showallcustomer(' + 1 + ',' + data.pageSize + ')">首页</a></li>';

                // 上一页链接
                html += '<li class="page-item' + (!data.hasPreviousPage ? ' disabled' : '') + '">';
                var previous;
                if (data.pageNum === 1) {
                    previous = data.pageNum;
                } else {
                    previous = data.pageNum - 1;
                }

                html += '<a class="page-link" onclick="showallcustomer(' + previous + ',' + data.pageSize + ')">上一页</a></li>';

                // 分页数字链接
                for (var i = 1; i <= data.pages; i++) {
                    html += '<li class="page-item' + (data.pageNum === i ? ' active' : '') + '">';
                    html += '<a class="page-link" onclick="showallcustomer(' + i + ',' + data.pageSize + ')">' + i + '</a></li>';
                }
                var next;
                if (data.pageNum === data.pages) {
                    next = data.pageNum;
                } else {
                    next = data.pageNum + 1;
                }
                // 下一页链接
                html += '<li class="page-item' + (!data.hasNextPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="showallcustomer(' + next + ',' + data.pageSize + ')">下一页</a></li>';

                // 尾页链接
                html += '<li class="page-item' + (data.isLastPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="showallcustomer(' + data.pages + ',' + data.pageSize + ')">尾页</a></li>';

                $("#page_all").append(html);
                $('#all_tbody').empty();
                var id;
                var username;
                var transbtn;
                // 循环遍历 JSON 数据并添加到表格中
                $.each(data.list, function (index, item) {
                    var row = '<tr>';
                    $.each(item, function (key, value) {
                        if (value != null && key !== 'isdelete') {
                            if (key === 'id') {
                                id = value;
                            }
                            if (key === 'username') {
                                username = value;
                            }
                            row += '<td style="text-align: center;">' + value + '</td>';
                        }
                    });
                    transbtn = '<button type="button" class="btn btn-primary" onclick="transAllCustomer(' + id + ',\'' + username + '\')">转移</button>';
                    row += '<td>' + transbtn + '</td></tr>'
                    $('#all_tbody').append(row);
                });
            },
        })
    }

    //添加用户信息
    function insertUserInfo() {
        $("#insert_user_Model").modal('show');
        $("#insert_user").on('click', function () {
            $.ajax({
                url: '/user/insertUserInfo',
                type: 'post',
                dataType: 'json',
                data: {
                    account: $("#insert_user_account").val(),
                    password: $("#insert_user_password").val(),
                    tel: $("#insert_user_tel").val(),
                    username: $("#insert_user_name").val(),
                    email: $("#insert_user_email").val(),
                    usertype: $("#insert_user_type").val(),
                    isdelete: 1,
                },
                success: function (data) {
                    if (data === 1) {
                        alert("添加成功");
                        window.location.href = '/customer/toCrm';
                    }
                }
            })
        })

    }

    //修改用户信息
    function updateUserInfo(id) {
        console.log(id);
        $("#update_user_Model").modal('show');
        $.ajax({
            url: '/user/selectUserInfo',
            type: 'post',
            dataType: 'json',
            data: {
                id: id,
            },
            success: function (data) {
                var list = data.list;
                $("#user_account").val(list[0].account);
                $("#user_password").val(list[0].password);
                $("#repassword").val(list[0].password);
                $("#user_tel").val(list[0].tel);
                $("#user_name").val(list[0].username);
                $("#user_email").val(list[0].email);
                if (list[0].usertype == 1) {
                    $("#user_type").val("管理员");
                } else if (list[0].usertype == 2) {
                    $("#user_type").val("经理");
                } else if (list[0].usertype == 3) {
                    $("#user_type").val("员工");
                }
                $("#usertype").val(list[0].usertype);

                $('#update_user').on('click', function () {
                    $.ajax({
                        url: '/user/updateUserInfo',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            id: id,
                            account: $("#user_account").val(),
                            password: $("#user_password").val(),
                            tel: $("#user_tel").val(),
                            username: $("#user_name").val(),
                            email: $("#user_email").val(),
                            usertype: $("#usertype").val(),
                        },
                        success: function (data) {
                            if (data === 1) {
                                alert("修改成功,请重新登录");
                                window.location.href = '/user/toLogin';
                            }
                        }
                    })
                })
            },
        })
    }

    //删除员工信息
    function deluser(id) {
        $("#del_user_Model").modal("show");

        $("#del_user").on("click", function () {
            $.ajax({
                url: "/user/deleteUserInfo",
                type: "post",
                data: {
                    id: id,
                },
                dataType: "json",
                success: function (data) {
                    if (data === 1) {
                        alert("用户信息删除成功");
                        window.location.href = '/customer/toCrm';
                    }
                },
            });
        })

    }

    //转移客户信息
    function transcustomer(id) {
        $("#trans_Model").modal("show");
        //选择器，选择要分享给的用户
        $.ajax({
            url: "/user/selectUserInfo",
            type: "POST",
            dataType: "json",
            success: (data) => {
                $("#trans_select").empty();
                let list = data.list;
                let opt = '';
                for (let i = 0; i < list.length; i++) {
                    if (list[i].username != $("#username").val()) {
                        opt += '<option value="' + list[i].id + '">' + list[i].username + '</option>';
                    }
                }
                $("#trans_select").append(opt);
                //点击转移客户信息
                $("#trans_add").on('click', function () {
                    $.ajax({
                        url: '/customer/updateCustomer',
                        type: 'post',
                        data: {
                            id: id,
                            userid: $("#trans_select").val(),
                        },
                        success: function (data) {
                            if (data === 1) {
                                alert("转移成功");
                                window.location.href = '/customer/toCrm';
                            }
                        }
                    })
                });
            },
        })
    }

    //分享客户
    function sharecustomer(id) {
        $("#share_Model").modal("show");
        //选择器，选择要分享给的用户
        $.ajax({
            url: "/user/selectUserInfo",
            type: "POST",
            dataType: "json",
            success: (data) => {
                $("#share_select").empty();
                let list = data.list;
                let opt = '';
                for (let i = 0; i < list.length; i++) {
                    if (list[i].username != $("#username").val()) {
                        opt += '<option value="' + list[i].id + '">' + list[i].username + '</option>';
                    }
                }
                $("#share_select").append(opt);
                //点击共享客户信息
                $("#share_add").on('click', function () {
                    $.ajax({
                        url: '/share/shareCustomer',
                        type: 'post',
                        data: {
                            customerid: id,
                            userid: $("#share_select").val(),
                        },
                        success: function (data) {
                            if (data === 1) {
                                alert("共享成功");
                                window.location.href = '/customer/toCrm';
                            } else {
                                alert("分享的用户已存在此客户共享,共享失败");
                            }
                        }
                    })
                });
            },
        })
    }

    //删除客户信息
    function delcustomer(id) {
        $("#del_Model").modal("show");

        $("#del_customer").on("click", function () {
            $.ajax({
                url: "/customer/deleteCustomer",
                type: "post",
                data: {
                    id: id,
                },
                dataType: "json",
                success: function (data) {
                    if (data === 1) {
                        alert("客户信息删除成功");
                        window.location.href = '/customer/toCrm';
                    }
                },
            });
        })

    }

    //修改客户信息,数据回显到表上
    function editcustomer(id) {
        $("#updateModel").modal('show');
        $.ajax({
            url: "/customer/selectCustomer",
            type: "post",
            data: {
                id: id,
                userid: $("#userid").val(),
            },
            dataType: "json",
            success: (data) => {
                let list = data.list;
                $("#name").val(list[0].name);
                $("#address").val(list[0].address);
                $("#contact").val(list[0].contact);
                $("#tel").val(list[0].tel);
                $("#email").val(list[0].email);

                $('#customerupdate').on('click', function () {
                    var formdata = $("#updateForm").serialize();
                    formdata += '&id=' + id;
                    $.ajax({
                        url: '/customer/updateCustomer',
                        type: 'post',
                        data: formdata,
                        success: function (data) {
                            if (data === 1) {
                                alert("客户信息修改成功");
                                window.location.href = '/customer/toCrm';
                            }
                        }
                    })
                });//客户修改提交
            }
        })
    }

    //修改拜访记录,数据回显到表上
    function editvisit(id) {
        $("#update_visit_Model").modal('show');
        $.ajax({
            url: "/visit/selectCustomerVisit",
            type: "post",
            data: {
                id: id,
                userid: $("#userid").val(),
            },
            dataType: "json",
            success: (data) => {
                let list = data.list;
                $("#visit_content").val(list[0].content);
                $('#update_visit').on('click', function () {
                    $.ajax({
                        url: '/visit/updateCustomerVisit',
                        type: 'post',
                        data: {
                            id: id,
                            content: $("#visit_content").val(),
                        },
                        success: function (data) {
                            if (data === 1) {
                                alert("客户拜访信息修改成功");
                                window.location.href = '/customer/toCrm';
                            }
                        }
                    })
                });//客户修改提交
            }
        })
    }

    //添加拜访信息
    function addvisit(id) {
        $("#add_visit_Model").modal('show');

        $("#visit_add").on('click', function () {
            $.ajax({
                url: '/visit/insertCustomerVisit',
                type: 'post',
                dataType: 'json',
                data: {
                    customerid: id,
                    userid: $("#userid").val(),
                    content: $("#add_visit_content").val(),
                },
                success: function (data) {
                    if (data === 1) {
                        alert("客户拜访记录添加成功");
                        window.location.href = '/customer/toCrm';
                    }
                },
            });
        });
    }

    //查看所有员工
    function showalluser(pageNum, pageSize) {
        $.ajax({
            url: '/user/selectUserInfo',
            type: 'post',
            data: {
                usertype: $("#type").val(),
                pageNum: pageNum,
                pageSize: pageSize,
            },
            success: function (data) {
                $("#page_user").empty();
                var html = '';
                html += '<li class="page-item' + (data.isFirstPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="showalluser(' + 1 + ',' + data.pageSize + ')">首页</a></li>';

                // 上一页链接
                html += '<li class="page-item' + (!data.hasPreviousPage ? ' disabled' : '') + '">';
                var previous;
                if (data.pageNum === 1) {
                    previous = data.pageNum;
                } else {
                    previous = data.pageNum - 1;
                }

                html += '<a class="page-link" onclick="showalluser(' + previous + ',' + data.pageSize + ')">上一页</a></li>';

                // 分页数字链接
                for (var i = 1; i <= data.pages; i++) {
                    html += '<li class="page-item' + (data.pageNum === i ? ' active' : '') + '">';
                    html += '<a class="page-link" onclick="showalluser(' + i + ',' + data.pageSize + ')">' + i + '</a></li>';
                }
                var next;
                if (data.pageNum === data.pages) {
                    next = data.pageNum;
                } else {
                    next = data.pageNum + 1;
                }
                // 下一页链接
                html += '<li class="page-item' + (!data.hasNextPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="showalluser(' + next + ',' + data.pageSize + ')">下一页</a></li>';

                // 尾页链接
                html += '<li class="page-item' + (data.isLastPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="showalluser(' + data.pages + ',' + data.pageSize + ')">尾页</a></li>';

                $("#page_user").append(html);
                var resetbtn;
                var delbtn;
                var editbtn;
                var authoritybtn;
                var authority;
                $('#tbody_user').empty();
                var id;
                // 循环遍历 JSON 数据并添加到表格中
                $.each(data.list, function (index, item) {
                    var row = '<tr>';
                    var flag = true;
                    $.each(item, function (key, value) {
                        if (key !== 'usertype') {
                            if (key === "id") {
                                id = value;
                            }
                            if (key === "email" && value === null) {
                                value = '未填邮箱';
                            }
                            if (key === "isdelete") {
                                if (value === 1) {
                                    value = "在职";
                                } else if (value === 0) {
                                    value = "离职";
                                }
                            }
                            row += '<td style="text-align: center;">' + value + '</td>';
                        }
                        if (key === 'isdelete' && value === "离职") {
                            flag = false;
                        }
                        if (key === 'usertype'){
                            authority = value
                        }
                        
                    });
                    if (flag) {
                        editbtn = '<button type="button" class="btn btn-warning" onclick="updateUserInfo(' + id + ')">修改</button>';
                        resetbtn = '<button type="button" class="btn btn-info" onclick="resetUserInfo(' + id + ')">重置密码</button>';
                        delbtn = '<button type="button" class="btn btn-danger" onclick="deluser(' + id + ')">删除</button>';
                        authoritybtn ='';
                        if ($("#type").val() == 1){
                            authoritybtn = '<button type="button" class="btn btn-success" onclick="authorityUser(' + id +','+ authority + ')">更改权限</button>';
                        }
                    } else {
                        editbtn = '';
                        delbtn = '';
                        resetbtn='';
                    }
                    row += '<td>' + editbtn + '&nbsp;&nbsp;' +authoritybtn + '&nbsp;&nbsp;' + resetbtn + '&nbsp;&nbsp;' + delbtn + '&nbsp;&nbsp;</td></tr>';
                    $('#tbody_user').append(row);
                });
            },
        })
    }//查看所有员工

    //按姓名搜索员工
    function user_search(pageNum, pageSize) {
        $.ajax({
            url: '/user/selectUserInfo',
            type: 'post',
            data: {
                usertype: $("#type").val(),
                username: $('#search_user_username').val(),
                pageNum: pageNum,
                pageSize: pageSize,
            },
            success: function (data) {
                $("#page_user").empty();
                var html = '';
                html += '<li class="page-item' + (data.isFirstPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="user_search(' + 1 + ',' + data.pageSize + ')">首页</a></li>';

                // 上一页链接
                html += '<li class="page-item' + (!data.hasPreviousPage ? ' disabled' : '') + '">';
                var previous;
                if (data.pageNum === 1) {
                    previous = data.pageNum;
                } else {
                    previous = data.pageNum - 1;
                }

                html += '<a class="page-link" onclick="user_search(' + previous + ',' + data.pageSize + ')">上一页</a></li>';

                // 分页数字链接
                for (var i = 1; i <= data.pages; i++) {
                    html += '<li class="page-item' + (data.pageNum === i ? ' active' : '') + '">';
                    html += '<a class="page-link" onclick="user_search(' + i + ',' + data.pageSize + ')">' + i + '</a></li>';
                }
                var next;
                if (data.pageNum === data.pages) {
                    next = data.pageNum;
                } else {
                    next = data.pageNum + 1;
                }
                // 下一页链接
                html += '<li class="page-item' + (!data.hasNextPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="user_search(' + next + ',' + data.pageSize + ')">下一页</a></li>';

                // 尾页链接
                html += '<li class="page-item' + (data.isLastPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="user_search(' + data.pages + ',' + data.pageSize + ')">尾页</a></li>';

                $("#page_user").append(html);
                var delbtn;
                var editbtn;
                $('#tbody_user').empty();
                var id;
                // 循环遍历 JSON 数据并添加到表格中
                $.each(data.list, function (index, item) {
                    var row = '<tr>';
                    var flag = true;
                    $.each(item, function (key, value) {
                        if (key !== 'usertype') {
                            if (key === "id") {
                                id = value;
                            }
                            if (key === "email" && value === null) {
                                value = '未填邮箱';
                            }
                            if (key === "isdelete") {
                                if (value === 1) {
                                    value = "在职";
                                } else if (value === 0) {
                                    value = "离职";
                                }
                            }
                            row += '<td style="text-align: center;">' + value + '</td>';
                        }
                        if (key === 'isdelete' && value === "离职") {
                            flag = false;
                        }
                    });
                    if (flag) {
                        editbtn = '<button type="button" class="btn btn-warning" onclick="updateUserInfo(' + id + ')">修改</button>';
                        delbtn = '<button type="button" class="btn btn-danger" onclick="deluser(' + id + ')">删除</button>';
                    } else {
                        editbtn = '';
                        delbtn = '';
                    }
                    row += '<td>' + editbtn + '&nbsp;&nbsp;' + delbtn + '&nbsp;&nbsp;</td></tr>';
                    $('#tbody_user').append(row);
                });
            },
        })
    }

    //按姓名搜索客户信息
    function custom_all_search(pageNum, pageSize) {
        $.ajax({
            url: '/customer/selectCustomer',
            type: 'post',
            data: {
                name: $('#search_all_username').val(),
                pageNum: pageNum,
                pageSize: pageSize,
            },
            success: function (data) {
                $("#page_all").empty();
                var html = '';
                html += '<li class="page-item' + (data.isFirstPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="custom_all_search(' + 1 + ',' + data.pageSize + ')">首页</a></li>';

                // 上一页链接
                html += '<li class="page-item' + (!data.hasPreviousPage ? ' disabled' : '') + '">';
                var previous;
                if (data.pageNum === 1) {
                    previous = data.pageNum;
                } else {
                    previous = data.pageNum - 1;
                }
                html += '<a class="page-link" onclick="custom_all_search(' + previous + ',' + data.pageSize + ')">上一页</a></li>';

                // 分页数字链接
                for (var i = 1; i <= data.pages; i++) {
                    html += '<li class="page-item' + (data.pageNum === i ? ' active' : '') + '">';
                    html += '<a class="page-link" onclick="custom_all_search(' + i + ',' + data.pageSize + ')">' + i + '</a></li>';
                }
                var next;
                if (data.pageNum === data.pages) {
                    next = data.pageNum;
                } else {
                    next = data.pageNum + 1;
                }
                // 下一页链接
                html += '<li class="page-item' + (!data.hasNextPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="custom_all_search(' + next + ',' + data.pageSize + ')">下一页</a></li>';
                // 尾页链接
                html += '<li class="page-item' + (data.isLastPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="custom_all_search(' + data.pages + ',' + data.pageSize + ')">尾页</a></li>';

                $("#page_all").append(html);

                $('#all_tbody').empty();
                var id;
                var username;
                var transbtn;
                // 循环遍历 JSON 数据并添加到表格中
                $.each(data.list, function (index, item) {
                    var row = '<tr>';
                    $.each(item, function (key, value) {
                        if (value !== null && key !== 'isdelete') {
                            if (key === "id") {
                                id = value;
                            }
                            if (key === "username") {
                                username = value;
                            }
                            row += '<td style="text-align: center;">' + value + '</td>';
                        }
                    });
                    transbtn = '<button type="button" class="btn btn-primary" onclick="transAllCustomer(' + id + ',\'' + username + '\')">转移</button>';
                    row += '<td>' + transbtn + '</td></tr>';
                    $('#all_tbody').append(row);
                });
            },
        })
    }


    //所有客户拜访记录
    function showallvisit(pageNum, pageSize) {
        $.ajax({
            url: '/visit/selectCustomerVisit',
            type: 'post',
            data: {
                pageNum: pageNum,
                pageSize: pageSize,
            },
            success: function (data) {
                $("#page_all_visit").empty();
                var html = '';
                html += '<li class="page-item' + (data.isFirstPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="showallvisit(' + 1 + ',' + data.pageSize + ')">首页</a></li>';

                // 上一页链接
                html += '<li class="page-item' + (!data.hasPreviousPage ? ' disabled' : '') + '">';
                var previous;
                if (data.pageNum === 1) {
                    previous = data.pageNum;
                } else {
                    previous = data.pageNum - 1;
                }

                html += '<a class="page-link" onclick="showallvisit(' + previous + ',' + data.pageSize + ')">上一页</a></li>';

                // 分页数字链接
                for (var i = 1; i <= data.pages; i++) {
                    html += '<li class="page-item' + (data.pageNum === i ? ' active' : '') + '">';
                    html += '<a class="page-link" onclick="showallvisit(' + i + ',' + data.pageSize + ')">' + i + '</a></li>';
                }
                var next;
                if (data.pageNum === data.pages) {
                    next = data.pageNum;
                } else {
                    next = data.pageNum + 1;
                }
                // 下一页链接
                html += '<li class="page-item' + (!data.hasNextPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="showallvisit(' + next + ',' + data.pageSize + ')">下一页</a></li>';

                // 尾页链接
                html += '<li class="page-item' + (data.isLastPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="showallvisit(' + data.pages + ',' + data.pageSize + ')">尾页</a></li>';

                $("#page_all_visit").append(html);


                $('#visit_all_tbody').empty();
                var id;
                // 循环遍历 JSON 数据并添加到表格中
                $.each(data.list, function (index, item) {
                    var row = '<tr>';
                    $.each(item, function (key, value) {
                        if (value != null) {
                            if (key === "id") {
                                id = value;
                            }
                            row += '<td style="text-align: center;">' + value + '</td>';
                        }
                    });
                    $('#visit_all_tbody').append(row);
                });
            },
        });
    }

    //按姓名查询客户拜访记录
    function visit_search_all(pageNum, pageSize) {
        $.ajax({
            url: '/visit/selectCustomerVisit',
            type: 'post',
            dataType: 'json',
            data: {
                name: $("#search_visit_all").val(),
                pageNum: pageNum,
                pageSize: pageSize,
            },
            success: function (data) {
                $("#page_all_visit").empty();
                var html = '';
                html += '<li class="page-item' + (data.isFirstPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="visit_search_all(' + 1 + ',' + data.pageSize + ')">首页</a></li>';

                // 上一页链接
                html += '<li class="page-item' + (!data.hasPreviousPage ? ' disabled' : '') + '">';
                var previous;
                if (data.pageNum === 1) {
                    previous = data.pageNum;
                } else {
                    previous = data.pageNum - 1;
                }

                html += '<a class="page-link" onclick="visit_search_all(' + previous + ',' + data.pageSize + ')">上一页</a></li>';

                // 分页数字链接
                for (var i = 1; i <= data.pages; i++) {
                    html += '<li class="page-item' + (data.pageNum === i ? ' active' : '') + '">';
                    html += '<a class="page-link" onclick="visit_search_all(' + i + ',' + data.pageSize + ')">' + i + '</a></li>';
                }
                var next;
                if (data.pageNum === data.pages) {
                    next = data.pageNum;
                } else {
                    next = data.pageNum + 1;
                }
                // 下一页链接
                html += '<li class="page-item' + (!data.hasNextPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="visit_search_all(' + next + ',' + data.pageSize + ')">下一页</a></li>';

                // 尾页链接
                html += '<li class="page-item' + (data.isLastPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="visit_search_all(' + data.pages + ',' + data.pageSize + ')">尾页</a></li>';

                $("#page_all_visit").append(html);

                $('#visit_all_tbody').empty();
                var id;
                // 循环遍历 JSON 数据并添加到表格中
                $.each(data.list, function (index, item) {
                    var row = '<tr>';
                    $.each(item, function (key, value) {
                        if (value != null) {
                            if (key === "id") {
                                id = value;
                            }
                            row += '<td style="text-align: center;">' + value + '</td>';
                        }
                    });
                    $('#visit_all_tbody').append(row);
                });
            },
        });
    }

    // 点击查看客户信息
    function queryAllCustomer(pageNum, pageSize) {
        $.ajax({
            url: '/customer/selectCustomer',
            type: 'post',
            data: {
                userid: $("#userid").val(),
                pageNum: pageNum,
                pageSize: pageSize,
            },
            success: function (data) {
                $("#page_customer").empty();
                var html = '';
                html += '<li class="page-item' + (data.isFirstPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="queryAllCustomer(' + 1 + ',' + data.pageSize + ')">首页</a></li>';

                // 上一页链接
                html += '<li class="page-item' + (!data.hasPreviousPage ? ' disabled' : '') + '">';
                var previous;
                if (data.pageNum === 1) {
                    previous = data.pageNum;
                } else {
                    previous = data.pageNum - 1;
                }

                html += '<a class="page-link" onclick="queryAllCustomer(' + previous + ',' + data.pageSize + ')">上一页</a></li>';

                // 分页数字链接
                for (var i = 1; i <= data.pages; i++) {
                    html += '<li class="page-item' + (data.pageNum === i ? ' active' : '') + '">';
                    html += '<a class="page-link" onclick="queryAllCustomer(' + i + ',' + data.pageSize + ')">' + i + '</a></li>';
                }
                var next;
                if (data.pageNum === data.pages) {
                    next = data.pageNum;
                } else {
                    next = data.pageNum + 1;
                }
                // 下一页链接
                html += '<li class="page-item' + (!data.hasNextPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="queryAllCustomer(' + next + ',' + data.pageSize + ')">下一页</a></li>';

                // 尾页链接
                html += '<li class="page-item' + (data.isLastPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="queryAllCustomer(' + data.pages + ',' + data.pageSize + ')">尾页</a></li>';

                $("#page_customer").append(html);
                var sharebtn;
                var delbtn;
                var transbtn;
                $('#tbody').empty();
                var id;
                // 循环遍历 JSON 数据并添加到表格中
                $.each(data.list, function (index, item) {
                    var row = '<tr>';
                    var flag = true;
                    $.each(item, function (key, value) {
                        if (value != null && key !== 'isdelete') {
                            if (key === "id") {
                                id = value;
                            }
                            if ($("#username").val() === value) {
                                sharebtn = '<button type="button" class="btn btn-success" onclick="sharecustomer(' + id + ')">共享</button>';
                                delbtn = '<button type="button" class="btn btn-danger" onclick="delcustomer(' + id + ')">删除</button>';
                                transbtn = '<button type="button" class="btn btn-primary" onclick="transcustomer(' + id + ')">转移</button>';
                            } else {
                                sharebtn = '';
                                delbtn = '';
                                transbtn = '';
                            }
                            row += '<td style="text-align: center;">' + value + '</td>';
                        }
                        if (key === 'isdelete' && value === 0) {
                            flag = false;
                        }
                    });
                    if (flag) {
                        var visitbtn = '<button type="button" class="btn btn-info" onclick="addvisit(' + id + ')">拜访</button>';
                        var editbtn = '<button type="button" class="btn btn-warning" onclick="editcustomer(' + id + ')">修改</button>';
                        row += '<td>' + visitbtn + '&nbsp;&nbsp;' + editbtn + '&nbsp;&nbsp;' + delbtn + '&nbsp;&nbsp;' + sharebtn + '&nbsp;&nbsp;' + transbtn + '</td></tr>';
                        $('#tbody').append(row);
                    }
                });
            },
        })
    }

    //按姓名查询客户
    function custom_search(pageNum, pageSize) {
        $.ajax({
            url: '/customer/selectCustomer',
            type: 'post',
            dataType: 'json',
            data: {
                userid: $("#userid").val(),
                name: $("#search_username").val(),
                pageNum: pageNum,
                pageSize: pageSize,
            },
            success: function (data) {
                $("#page_customer").empty();
                var html = '';
                html += '<li class="page-item' + (data.isFirstPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="custom_search(' + 1 + ',' + data.pageSize + ')">首页</a></li>';

                // 上一页链接
                html += '<li class="page-item' + (!data.hasPreviousPage ? ' disabled' : '') + '">';
                var previous;
                if (data.pageNum === 1) {
                    previous = data.pageNum;
                } else {
                    previous = data.pageNum - 1;
                }

                html += '<a class="page-link" onclick="custom_search(' + previous + ',' + data.pageSize + ')">上一页</a></li>';

                // 分页数字链接
                for (var i = 1; i <= data.pages; i++) {
                    html += '<li class="page-item' + (data.pageNum === i ? ' active' : '') + '">';
                    html += '<a class="page-link" onclick="custom_search(' + i + ',' + data.pageSize + ')">' + i + '</a></li>';
                }
                var next;
                if (data.pageNum === data.pages) {
                    next = data.pageNum;
                } else {
                    next = data.pageNum + 1;
                }
                // 下一页链接
                html += '<li class="page-item' + (!data.hasNextPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="custom_search(' + next + ',' + data.pageSize + ')">下一页</a></li>';

                // 尾页链接
                html += '<li class="page-item' + (data.isLastPage ? ' disabled' : '') + '">';
                html += '<a class="page-link" onclick="custom_search(' + data.pages + ',' + data.pageSize + ')">尾页</a></li>';

                $("#page_customer").append(html);
                var sharebtn;
                var delbtn;
                var transbtn;
                $('#tbody').empty();
                var id;
                // 循环遍历 JSON 数据并添加到表格中
                $.each(data.list, function (index, item) {
                    var row = '<tr>';
                    var flag = true;
                    $.each(item, function (key, value) {
                        if (value != null && key !== "isdelete") {
                            if (key === "id") {
                                id = value;
                            }
                            if ($("#username").val() === value) {
                                sharebtn = '<button type="button" class="btn btn-success" onclick="sharecustomer(' + id + ')">共享</button>';
                                delbtn = '<button type="button" class="btn btn-danger" onclick="delcustomer(' + id + ')">删除</button>';
                                transbtn = '<button type="button" class="btn btn-primary" onclick="transcustomer(' + id + ')">转移</button>';
                            } else {
                                sharebtn = '';
                                delbtn = '';
                                transbtn = '';
                            }
                            row += '<td style="text-align: center;">' + value + '</td>';
                        }
                        if (key === 'isdelete' && value === 0) {
                            flag = false;
                        }
                    });
                    if (flag) {
                        var visitbtn = '<button type="button" class="btn btn-info" onclick="addvisit(' + id + ')">拜访</button>';
                        var editbtn = '<button type="button" class="btn btn-warning" onclick="editcustomer(' + id + ')">修改</button>';
                        row += '<td>' + visitbtn + '&nbsp;&nbsp;' + editbtn + '&nbsp;&nbsp;' + delbtn + '&nbsp;&nbsp;' + sharebtn + '&nbsp;&nbsp;' + transbtn + '</td></tr>';
                        $('#tbody').append(row);
                    }
                });
            },
        })
    };//按姓名查询用户
    $(function () {
        //页面切换
        $('.show').on('click', function (e) {
            var index = $(e.target).index(".show");
            $(".iframe").each(function (i) {
                if (index === i) {
                    $($('.iframe').get(i)).css('display', 'block');
                } else {
                    $($('.iframe').get(i)).css('display', 'none');
                }
            })
        })
        //弹出框设置
        $("[data-toggle='popover']").popover({
            html: true,
        });
        //添加客户信息
        $('#addcustomer').on('click', function () {
            $("#addModel").modal('show');
            $("#customeradd").on('click', function () {
                var formdata = $("#addForm").serialize();
                formdata += '&userid=' + $("#userid").val();
                $.ajax({
                    url: '/customer/insertCustomer',
                    type: 'post',
                    data: formdata,
                    success: function (data) {
                        if (data === 1) {
                            alert("客户信息添加成功");
                            window.location.href = '/customer/toCrm';
                        }
                    }
                })
            })
        });
        
        
        //修改客户表单的验证
        $('#updateForm').bootstrapValidator({
            message: '信息有误，请重新填写',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                name: {
                    message: '客户姓名不正确',
                    validators: {
                        notEmpty: {
                            message: '客户姓名不能为空'
                        },
                        stringLength: {
                            min: 2,
                            max: 5,
                            message: '客户姓名格式应该为2-5个中文汉字'
                        },
                        regexp: {
                            regexp: /^[\u4e00-\u9fa5]{2,5}$/,
                            message: '客户姓名格式不正确',
                        }
                    }
                },
                address: {
                    message: '地址不正确',
                    validators: {
                        notEmpty: {
                            message: '地址不能为空'
                        },
                        stringLength: {
                            min: 5,
                            max: 30,
                            message: '地址格式应该为5-30个中文汉字'
                        },
                        regexp: {
                            regexp: /^[\u4e00-\u9fa5]{1,30}$/,
                            message: '地址格式不正确',
                        }
                    }
                },
                contact: {
                    message: '联系人姓名不正确',
                    validators: {
                        notEmpty: {
                            message: '联系人姓名不能为空'
                        },
                        stringLength: {
                            min: 2,
                            max: 5,
                            message: '联系人姓名格式应该为2-5个中文汉字'
                        },
                        regexp: {
                            regexp: /^[\u4e00-\u9fa5]{2,5}$/,
                            message: '联系人姓名格式不正确',
                        }
                    }
                },
                tel: {
                    message: '联系方式不正确',
                    validators: {
                        notEmpty: {
                            message: '联系方式不能为空'
                        },
                        stringLength: {
                            min: 3,
                            max: 20,
                            message: '联系方式格式应该为11个数字'
                        },
                        regexp: {
                            regexp: /^[0-9]{11}$/,
                            message: '账号格式不正确',
                        }
                    }
                },
                email: {
                    message: '邮箱不正确',
                    validators: {
                        emailAddress: {
                            message: '请输入正确的邮件地址如：123@qq.com'
                        }
                    }
                },
            }
        })
            .on('success.form.bv', function (e) {
                //阻止表单提交
                e.preventDefault();
                // Get the form instance
                var $form = $(e.target);
                // Get the BootstrapValidator instance
                var bv = $form.data('bootstrapValidator');
                //使用ajax提交
                $.post($form.attr('action'), $form.serialize(), function (result) {
                    console.log(result);
                }, 'json');
            });
        //添加客户表单的验证
        $('#addForm').bootstrapValidator({
            message: '信息有误，请重新填写',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                name: {
                    message: '客户姓名不正确',
                    validators: {
                        notEmpty: {
                            message: '客户姓名不能为空'
                        },
                        stringLength: {
                            min: 2,
                            max: 5,
                            message: '客户姓名格式应该为2-5个中文汉字'
                        },
                        regexp: {
                            regexp: /^[\u4e00-\u9fa5]{2,5}$/,
                            message: '客户姓名格式不正确',
                        }
                    }
                },
                address: {
                    message: '地址不正确',
                    validators: {
                        notEmpty: {
                            message: '地址不能为空'
                        },
                        stringLength: {
                            min: 5,
                            max: 30,
                            message: '地址格式应该为5-30个中文汉字'
                        },
                        regexp: {
                            regexp: /^[\u4e00-\u9fa5]{1,30}$/,
                            message: '地址格式不正确',
                        }
                    }
                },
                contact: {
                    message: '联系人姓名不正确',
                    validators: {
                        notEmpty: {
                            message: '联系人姓名不能为空'
                        },
                        stringLength: {
                            min: 2,
                            max: 5,
                            message: '联系人姓名格式应该为2-5个中文汉字'
                        },
                        regexp: {
                            regexp: /^[\u4e00-\u9fa5]{2,5}$/,
                            message: '联系人姓名格式不正确',
                        }
                    }
                },
                tel: {
                    message: '联系方式不正确',
                    validators: {
                        notEmpty: {
                            message: '联系方式不能为空'
                        },
                        stringLength: {
                            min: 3,
                            max: 20,
                            message: '联系方式格式应该为11个数字'
                        },
                        regexp: {
                            regexp: /^[0-9]{11}$/,
                            message: '账号格式不正确',
                        }
                    }
                },
                email: {
                    message: '邮箱不正确',
                    validators: {
                        emailAddress: {
                            message: '请输入正确的邮件地址如：123@qq.com'
                        }
                    }
                },
            }
        })
            .on('success.form.bv', function (e) {
                //阻止表单提交
                e.preventDefault();
                // Get the form instance
                var $form = $(e.target);
                // Get the BootstrapValidator instance
                var bv = $form.data('bootstrapValidator');
                //使用ajax提交
                $.post($form.attr('action'), $form.serialize(), function (result) {
                    console.log(result);
                }, 'json');
            });
        
        //添加用户表单的验证
        $('#insert_user_Form').bootstrapValidator({
            message: '信息不正确，请重新输入',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                account: {
                    message: '账号不正确',
                    validators: {
                        notEmpty: {
                            message: '账号不能为空'
                        },
                        stringLength: {
                            min: 3,
                            max: 20,
                            message: '账号格式应该为3-20个字符'
                        },
                        remote: {
                            url: "/user/repeatAccount",
                            message: '用户名已经存在,请更换另一个用户名',
                            delay:800,
                        },
                        regexp: {
                            regexp: /^[0-9|a-z|A-Z|\u4e00-\u9fa5]{3,20}$/,
                            message: '账号格式不正确',
                        }
                    }
                },
                password: {
                    validators: {
                        notEmpty: {
                            message: '密码不能为空'
                        },
                        stringLength: {
                            min: 6,
                            max: 20,
                            message: '密码格式应该为6-20个大小写字母或数字'
                        },
                        regexp: {
                            regexp: /^[0-9|a-z|A-Z]{6,20}$/,
                            message: '密码格式不正确'
                        },
                        identical: {//相同
                            field: 'repassword', //需要进行比较的input name值
                            message: '两次密码不一致'
                        }
                    }
                },
                repassword: {
                    validators: {
                        identical: {//相同
                            field: 'password', //需要进行比较的input name值
                            message: '两次密码不一致'
                        }
                    }
                },
                tel: {
                    message: '联系方式不正确',
                    validators: {
                        notEmpty: {
                            message: '联系方式不能为空'
                        },
                        stringLength: {
                            min: 3,
                            max: 20,
                            message: '联系方式格式应该为11个数字'
                        },
                        regexp: {
                            regexp: /^[0-9]{11}$/,
                            message: '账号格式不正确',
                        }
                    }
                },
                username: {
                    message: '姓名不正确',
                    validators: {
                        notEmpty: {
                            message: '姓名不能为空'
                        },
                        stringLength: {
                            min: 2,
                            max: 5,
                            message: '姓名格式应该为2-5个中文汉字'
                        },
                        regexp: {
                            regexp: /^[\u4e00-\u9fa5]{2,5}$/,
                            message: '姓名格式不正确',
                        }
                    }
                },
                email: {
                    message: '邮箱不正确',
                    validators: {
                        emailAddress: {
                            message: '请输入正确的邮件地址如：123@qq.com'
                        }
                    }
                },
            }
        }).on('success.form.bv',function(e) {
            //阻止表单提交
            e.preventDefault();
            // Get the form instance
            var $form = $(e.target);
            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');
            //使用ajax提交
            $.post($form.attr('action'),$form.serialize(),function(result) {
                console.log(result);
            },'json');
        });


        //修改用户表单的验证
        $('#update_user_Model').bootstrapValidator({
            message: '信息不正确，请重新输入',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                account: {
                    message: '账号不正确',
                    validators: {
                        notEmpty: {
                            message: '账号不能为空'
                        },
                        stringLength: {
                            min: 3,
                            max: 20,
                            message: '账号格式应该为3-20个字符'
                        },
                        remote: {
                            url: "/user/repeatAccount",
                            message: '用户名已经存在,请更换另一个用户名',
                            delay:800,
                        },
                        regexp: {
                            regexp: /^[0-9|a-z|A-Z|\u4e00-\u9fa5]{3,20}$/,
                            message: '账号格式不正确',
                        }
                    }
                },
                password: {
                    validators: {
                        notEmpty: {
                            message: '密码不能为空'
                        },
                        stringLength: {
                            min: 6,
                            max: 20,
                            message: '密码格式应该为6-20个大小写字母或数字'
                        },
                        regexp: {
                            regexp: /^[0-9|a-z|A-Z]{6,20}$/,
                            message: '密码格式不正确'
                        },
                        identical: {//相同
                            field: 'repassword', //需要进行比较的input name值
                            message: '两次密码不一致'
                        }
                    }
                },
                repassword: {
                    validators: {
                        identical: {//相同
                            field: 'password', //需要进行比较的input name值
                            message: '两次密码不一致'
                        }
                    }
                },
                tel: {
                    message: '联系方式不正确',
                    validators: {
                        notEmpty: {
                            message: '联系方式不能为空'
                        },
                        stringLength: {
                            min: 3,
                            max: 20,
                            message: '联系方式格式应该为11个数字'
                        },
                        regexp: {
                            regexp: /^[0-9]{11}$/,
                            message: '账号格式不正确',
                        }
                    }
                },
                username: {
                    message: '姓名不正确',
                    validators: {
                        notEmpty: {
                            message: '姓名不能为空'
                        },
                        stringLength: {
                            min: 2,
                            max: 5,
                            message: '姓名格式应该为2-5个中文汉字'
                        },
                        regexp: {
                            regexp: /^[\u4e00-\u9fa5]{2,5}$/,
                            message: '姓名格式不正确',
                        }
                    }
                },
                email: {
                    message: '邮箱不正确',
                    validators: {
                        emailAddress: {
                            message: '请输入正确的邮件地址如：123@qq.com'
                        }
                    }
                },
            }
        }).on('success.form.bv',function(e) {
            //阻止表单提交
            e.preventDefault();
            // Get the form instance
            var $form = $(e.target);
            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');
            //使用ajax提交
            $.post($form.attr('action'),$form.serialize(),function(result) {
                console.log(result);
            },'json');
        });
    });
</script>
</html>
